import grails.util.Environment

import com.dongwq.PageDemo
import com.dongwq.User

class BootStrap {

	def init = { servletContext ->

		if( Environment.DEVELOPMENT == Environment.current) {
		
			createPageDemos();
			createUsers()  //add User when start
			
			servletContext.defaultPic = "${servletContext.contextPath}/images/photos/thumb_image1.jpg"
		}
	}
	def destroy = {
	}

	def createPageDemos() {
		createPageDemo("blueprintDemo")
		createPageDemo("blueprintSampleDemo")
	}
	def createPageDemo(def str) {
		new PageDemo(name:str, uri:str).save();
	}

	def createUsers(){
		
		new User(username:"root", password:"admin", uri:"root", email:"dd@dd.com" ).save();
		new User(username:"dong", password:"dong", uri:"dong", email:"dd@dd.com" ).save();
		new User(username:"jinglj", password:"jinglj", uri:"jinglj", email:"dd@dd.com" ).save();
		new User(username:"dongwq", password:"dongwq", uri:"dongwq", email:"dd@dd.com" ).save();
	}
}
